home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / Extras / ODE / er.report < prev    next >
Encoding:
Text File  |  1992-01-22  |  1.5 KB  |  70 lines

  1. \ Error Reporting
  2. \ This is used by ODE.
  3. \ I would not recommend using this for other programs.
  4. \ It was developed for host independance.
  5. \
  6. \ For a turnkey application, you may want to modify this code.
  7. \
  8. \ Author: Phil Burk
  9. \ Copyright 1986 Delta Research
  10. \
  11. \ MOD: PLB 4/27/88 Toned down error messages, FATAL -> ERROR-STOP
  12. \ MOD: PLB 3/21/90 Removed call to TIB.DUMP
  13. \ 00001 PLB 1/22/92 Use 0 ERROR instead of ABORT
  14.  
  15. include? tib.dump ju:ajf_debug
  16. include? bell jo:ajf_base
  17. include? unravel ju:unravel
  18.  
  19. ANEW TASK-ER.REPORT
  20.  
  21. .NEED $.
  22. : $. ( $string -- , print it )
  23.     count type
  24. ;
  25. .THEN
  26.  
  27. 0 CONSTANT ER_WARNING    ( Declare levels. )
  28. 1 CONSTANT ER_RETURN
  29. 2 CONSTANT ER_FATAL
  30.  
  31. CREATE ER-TRACEBACK? FALSE ,  ( should we trace back if bombed)
  32.  
  33. : ER.TRACEBACK
  34.     er-traceback? @
  35.     IF ." Calling Sequence: "
  36.         unravel cr ." Hit any key to continue!" key drop cr
  37.     THEN
  38. ;
  39.  
  40. ( Report location of error and cause, abort if FATAL )
  41. : ER.SHOW ( $PLACE $MESSAGE $LEVEL -- , SHOW ERROR )
  42.     cr ." !!! " $. ."  in " swap $.
  43.     ."  - " $. ." !" bell cr
  44. ;
  45.  
  46. : (ER.REPORT) ( $PLACE $MESSAGE LEVEL -- , reports error )
  47. \     cr ." TIB = " tib.dump cr
  48. \     ." Hit key to continue." cr key drop
  49.     >newline
  50.     CASE
  51.         ER_WARNING OF " WARNING" er.show
  52.         ENDOF
  53.         ER_RETURN OF er.traceback " ERROR" er.show
  54.         ENDOF
  55.         ER_FATAL OF er.traceback " ERROR-STOP"
  56.             er.show 0 error
  57.         ENDOF
  58.         ." Unrecognized Error LEVEL = " . CR
  59.         er.traceback " UNKNOWN" er.show 0 error
  60.     ENDCASE
  61. ;
  62.  
  63. defer ER.REPORT
  64. 'c (er.report) is er.report
  65.  
  66. : TEST.ERROR  " TEST.ERROR" " Something Terrible Happened!"
  67.     ER_RETURN   ER.REPORT
  68. ;
  69.  
  70.